<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .area {
      width: 100px;
      height: 100px;
      background-color: pink;
    }
  </style>
</head>

<body>
  <div id="app"></div>

  <template id="my-app">
    <!-- 完整写法：v-on:监听的事件=”methods中的方法“ -->
    <button v-on:click="btnClick">按钮1</button>
    <div class="area" v-on:mousemove="mousemove">div</div>

    <!-- 语法糖 -->
    <button @click="btnClick">按钮2</button>

    <!-- 绑定一个表达式 -->
    <button @click="counter++">{{ counter }}</button>

    <!-- 绑定一个表达式 -->
    <div class="area" v-on="{click: btnClick, mousemove: mousemove }"></div>
    <div class="area" @="{click: btnClick, mousemove: mousemove }"></div>
  </template>

  <script src="../js/vue.js"></script>

  <script>
    const App = {
      template: "#my-app",
      data() {
        return {
          message: "Hello World",
          counter: 100
        }
      },
      methods: {
        btnClick() {
          console.log("按钮1发生了点击");
        },
        mousemove() {
          console.log("鼠标发生了移动");
        }
      }
    }

    Vue.createApp(App).mount("#app");
  </script>
</body>

</html>